//
//
#include "IGraph.h"

namespace Structure
{
	IGraph::IGraph()
	{

	}

	IGraph::IGraph(const IGraph& _igraph)
	{

	}

	IGraph::~IGraph()
	{

	}

	inline virtual bool isValid()
	{
		// node data is unnecessary, so effectiveness depend on adjacency matrix
		return m_matrix.isOrderMatrix();
	}

	inline virtual void alloc(unsigned int _length)
	{
		// allocate memory
		m_matrix.alloc(_length, _length);
		// initialize data
		initialize();
	}

	inline virtual void free()
	{
		// free all buffer of matrix
		m_matrix.free();
	}

	inline virtual void copy(IGraph* _igraph)
	{
		m_matrix = _igraph.m_matrix;
	}

	inline void initialize()
	{
		const Number& zero = _GraphStructure::getNumberZero();
		const Number& endless = _GraphStructure::getNumberEndless();
		unsigned int node_count = m_matrix.getN();
		for(unsigned int i = 0; i < node_count; i++)
		{
			for(unsigned int j = 0; j < node_count; j++)
			{
				// set value
				if(i == j)
				{
					m_matrix.set(i, j, zero);
				}
				else
				{
					m_matrix.set(i, j, endless);
				}
			}// for: j
		}// for: i
	}
}